package com.alks.function.data.dto.chengKong.produce;


import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.math.BigDecimal;

@Getter
@Setter
@NoArgsConstructor
@ToString
public class PcLotGroupDto {

    @ApiModelProperty("配码")
    private String groupNo;

    @ApiModelProperty("PO")
    private String poNo;

    @ApiModelProperty("装箱方式")
    private String caseType;

    @ApiModelProperty("码制")
    private String sizeNotice;

    @ApiModelProperty("码制号码")
    private String sizeCode;

    private BigDecimal qty1;
    private BigDecimal qty2;
    private BigDecimal qty3;
    private BigDecimal qty4;
    private BigDecimal qty5;
    private BigDecimal qty6;
    private BigDecimal qty7;
    private BigDecimal qty8;
    private BigDecimal qty9;
    private BigDecimal qty10;
    private BigDecimal qty11;
    private BigDecimal qty12;
    private BigDecimal qty13;
    private BigDecimal qty14;
    private BigDecimal qty15;
    private BigDecimal qty16;
    private BigDecimal qty17;
    private BigDecimal qty18;
    private BigDecimal qty19;
    private BigDecimal qty20;
    private BigDecimal qty21;
    private BigDecimal qty22;
    private BigDecimal qty23;
    private BigDecimal qty24;
    private BigDecimal qty25;
    private BigDecimal qty26;
    private BigDecimal qty27;
    private BigDecimal qty28;
    private BigDecimal qty29;
    private BigDecimal qty30;
    private BigDecimal qty31;
    private BigDecimal qty32;
    private BigDecimal qty33;
    private BigDecimal qty34;
    private BigDecimal qty35;
    private BigDecimal qty36;
    private BigDecimal qty37;
    private BigDecimal qty38;
    private BigDecimal qty39;
    private BigDecimal qty40;

    @ApiModelProperty(value = "出入库数量")
    private Integer qty;

    public BigDecimal getCount() {
        BigDecimal count = BigDecimal.ZERO;
        count = count.add(qty1 != null ? qty1 : BigDecimal.ZERO);
        count = count.add(qty2 != null ? qty2 : BigDecimal.ZERO);
        count = count.add(qty3 != null ? qty3 : BigDecimal.ZERO);
        count = count.add(qty4 != null ? qty4 : BigDecimal.ZERO);
        count = count.add(qty5 != null ? qty5 : BigDecimal.ZERO);
        count = count.add(qty6 != null ? qty6 : BigDecimal.ZERO);
        count = count.add(qty7 != null ? qty7 : BigDecimal.ZERO);
        count = count.add(qty8 != null ? qty8 : BigDecimal.ZERO);
        count = count.add(qty9 != null ? qty9 : BigDecimal.ZERO);
        count = count.add(qty10 != null ? qty10 : BigDecimal.ZERO);
        count = count.add(qty11 != null ? qty11 : BigDecimal.ZERO);
        count = count.add(qty12 != null ? qty12 : BigDecimal.ZERO);
        count = count.add(qty13 != null ? qty13 : BigDecimal.ZERO);
        count = count.add(qty14 != null ? qty14 : BigDecimal.ZERO);
        count = count.add(qty15 != null ? qty15 : BigDecimal.ZERO);
        count = count.add(qty16 != null ? qty16 : BigDecimal.ZERO);
        count = count.add(qty17 != null ? qty17 : BigDecimal.ZERO);
        count = count.add(qty18 != null ? qty18 : BigDecimal.ZERO);
        count = count.add(qty19 != null ? qty19 : BigDecimal.ZERO);
        count = count.add(qty20 != null ? qty20 : BigDecimal.ZERO);
        count = count.add(qty21 != null ? qty21 : BigDecimal.ZERO);
        count = count.add(qty22 != null ? qty22 : BigDecimal.ZERO);
        count = count.add(qty23 != null ? qty23 : BigDecimal.ZERO);
        count = count.add(qty24 != null ? qty24 : BigDecimal.ZERO);
        count = count.add(qty25 != null ? qty25 : BigDecimal.ZERO);
        count = count.add(qty26 != null ? qty26 : BigDecimal.ZERO);
        count = count.add(qty27 != null ? qty27 : BigDecimal.ZERO);
        count = count.add(qty28 != null ? qty28 : BigDecimal.ZERO);
        count = count.add(qty29 != null ? qty29 : BigDecimal.ZERO);
        count = count.add(qty30 != null ? qty30 : BigDecimal.ZERO);
        count = count.add(qty31 != null ? qty31 : BigDecimal.ZERO);
        count = count.add(qty32 != null ? qty32 : BigDecimal.ZERO);
        count = count.add(qty33 != null ? qty33 : BigDecimal.ZERO);
        count = count.add(qty34 != null ? qty34 : BigDecimal.ZERO);
        count = count.add(qty35 != null ? qty35 : BigDecimal.ZERO);
        count = count.add(qty36 != null ? qty36 : BigDecimal.ZERO);
        count = count.add(qty37 != null ? qty37 : BigDecimal.ZERO);
        count = count.add(qty38 != null ? qty38 : BigDecimal.ZERO);
        count = count.add(qty39 != null ? qty39 : BigDecimal.ZERO);
        count = count.add(qty40 != null ? qty40 : BigDecimal.ZERO);
        return count;
    }

    public BigDecimal getQty(int index) {
        if (index < 1 || index > 40) {
            throw new IllegalArgumentException("无效索引: " + index);
        }
        switch (index) {
            case 1:
                return qty1;
            case 2:
                return qty2;
            case 3:
                return qty3;
            case 4:
                return qty4;
            case 5:
                return qty5;
            case 6:
                return qty6;
            case 7:
                return qty7;
            case 8:
                return qty8;
            case 9:
                return qty9;
            case 10:
                return qty10;
            case 11:
                return qty11;
            case 12:
                return qty12;
            case 13:
                return qty13;
            case 14:
                return qty14;
            case 15:
                return qty15;
            case 16:
                return qty16;
            case 17:
                return qty17;
            case 18:
                return qty18;
            case 19:
                return qty19;
            case 20:
                return qty20;
            case 21:
                return qty21;
            case 22:
                return qty22;
            case 23:
                return qty23;
            case 24:
                return qty24;
            case 25:
                return qty25;
            case 26:
                return qty26;
            case 27:
                return qty27;
            case 28:
                return qty28;
            case 29:
                return qty29;
            case 30:
                return qty30;
            case 31:
                return qty31;
            case 32:
                return qty32;
            case 33:
                return qty33;
            case 34:
                return qty34;
            case 35:
                return qty35;
            case 36:
                return qty36;
            case 37:
                return qty37;
            case 38:
                return qty38;
            case 39:
                return qty39;
            case 40:
                return qty40;
            default:
                // 这里不应该到达，因为我们已经在if语句中检查了索引的有效性
                throw new IllegalStateException("Unexpected value: " + index);
        }
    }
}
